/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package DAO;

import DTO.DoiTuongDTO;
import DTO.Ghe;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 *
 * @author Tu Nguyen
 */
public class DoiTuongDAO {
     public static DoiTuongDTO Get(int id)
    {
        try
        {
            Connection con = DBConnect.Connect();
            String sql = String.format("Select * From doi_tuong Where id = %s", id);
            PreparedStatement ps = con.prepareStatement(sql);
            ResultSet rs = ps.executeQuery();
            
            DoiTuongDTO gh = new DoiTuongDTO();
            while(rs.next())
            {
                gh.id = rs.getInt("id");
                gh.giamgia = rs.getInt("giam_gia");
            }
            return gh;
        }
        catch (Exception ex)
        {
        }
        return null;
    }
    
}
